import { createRouter, createWebHashHistory } from "vue-router";
import "nprogress/nprogress.css";
import NProgress from "nprogress";
const routes = [
  { path: "/home",
    redirect: "/home/index",
    meta:{isLogin:true}
  },
  { path: "/",
    redirect: "/home/index",
    meta:{isLogin:true}
  },
  {
    path: "/home/consultation/releaseRequirets",
    redirect: "/home/consultation/releaseRequirets/department",
  },
  {
    path: "/home/consultation/doctorRegistIndex",
    redirect: "/home/consultation/doctorRegistIndex/department",
  },
  {
    path: "/home",
    component: () =>
      import(/* webpackChunkName:"home" */ "../views/home/home.vue"),
    children: [
      {
        path: "index",
        name: "homeIndex",
        component: () =>
          import(
            /* webpackChunkName:"home_index" */ "../views/home/homeIndex.vue"
          ),
      },
      {
        path: "consultation",
        name: "homeConsultation",
        component: () =>
          import(
            /* webpackChunkName:"home_consultation" */ "../views/home/consultation.vue"
          ),
        children: [
          {
            path: "releaseRequirets",
            name: "releaseRequirets",
            component: () =>
              import(
                /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/releaseRequirets/releaseRequirets.vue"
              ),
            children: [
              {
                path: "department",
                name: "department",
                component: () =>
                  import(
                    /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/releaseRequirets/department.vue"
                  ),
              },
              {
                path: "describe",
                name: "describe",
                component: () =>
                  import(
                    /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/releaseRequirets/describeCondition.vue"
                  ),
              },
              {
                path: "doctorCommunication",
                name: "doctorCommunication",
                component: () =>
                  import(
                    /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/releaseRequirets/doctorCommunication.vue"
                  ),
              },
              {
                path: "getPrescription",
                name: "getPrescription",
                component: () =>
                  import(
                    /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/releaseRequirets/getPrescription.vue"
                  ),
              },
            ],
          },
          {
            path: "releaseSuccess",
            name: "releaseSuccess",
            component: () =>
              import(
                /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/releaseRequirets/releaseSuccess.vue"
              ),
          },
          {
            path: "doctorRegistIndex",
            name: "doctorRegistIndex",
            component: () =>
              import(
                /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/doctorRegistration/doctorRegistIndex.vue"
              ),
            children: [
              {
                path: "department",
                name: "regDoctordepartment",
                component: () =>
                  import(
                    /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/doctorRegistration/regDoctordepartment.vue"
                  ),
              },
              {
                path: "docRegistration",
                name: "docRegistration",
                component: () =>
                  import(
                    /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/doctorRegistration/docRegistration.vue"
                  ),
              },
              {
                path: "describeCondition",
                name: "describeCondition",
                component: () =>
                  import(
                    /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/doctorRegistration/describeCondition.vue"
                  ),
              },
            ],
          },
          {
            path: "doctorDetails",
            name: "doctorDetails",
            component: () =>
              import(
                /* webpackChunkName:"home_consultation" */ "../components/patientComponents/consultation/doctorRegistration/doctorDetails.vue"
              ),
          },
          {
            path: "communication",
            name: "communication",
            component: () =>
              import(
                /* webpackChunkName:"home_consultation" */ "../components/commiunication/communication.vue"
              ),
          },
          {
            path: "payBill",
            name: "payBill",
            component: () =>
              import(
                /* webpackChunkName:"home_consultation" */ "../components/commiunication/payBill.vue"
              ),
          },
        ],
      },
      {
        path: "medicine",
        name: "homeMedicine",
        component: () =>
          import(
            /* webpackChunkName:"home_medicine" */ "../views/home/medicine.vue"
          ),
        children: [
          {
            path: "takeQrCode",
            name: "takeQrCode",
            component: () =>
              import(
                /* webpackChunkName:"home_medicine" */ "../components/patientComponents/medichaine/takeQrCode.vue"
              ),
          },
        ],
      },
      {
        path: "doctormyself",
        name: "doctormyself",
        meta:{isLogin:true},
        component: () =>
          import(
            /* webpackChunkName:"home_doctormyself" */ "../views/home/doctormyself.vue"
          ),
        children: [
          {
            path: "patientList",
            name: "patientList",
            component: () =>
              import(
                /* webpackChunkName:"home_doctormyself" */ "../components/doctorComponents/doctormyself/patientList.vue"
              ),
          },
        ],
      },
      {
        path:"logout",
        name:"logout",
        component: () =>
            import(
                /* webpackChunkName:"home_logout" */"../views/home/logout.vue"
                ),
      },
      {
        path: "patientmyself",
        name: "patientmyself",
        meta:{isLogin:true},
        component: () =>
          import(
            /* webpackChunkName:"home_patientmyself" */ "../views/home/patientmyself.vue"
          ),
      },
      {
        path: "receivePatient",
        name: "receivePatient",
        component: () =>
          import(
            /* webpackChunkName:"home_receivePatient" */ "../views/home/receivePatient.vue"
          ),
        children: [
          {
            path: "goonlined",
            name: "goonlined",
            component: () =>
              import(
                /* webpackChunkName:"home_receivePatient" */ "../components/doctorComponents/receivePatient/goonlined.vue"
              ),
            children: [
              {
                path: "patientDetails",
                name: "patientDetails",
                component: () =>
                  import(
                    /* webpackChunkName:"home_receivePatient" */ "../components/doctorComponents/receivePatient/patientDetails.vue"
                  ),
              },
            ],
          },
        ],
      },
      {
        path: "patient",
        name: "patient",
        component: () =>
          import(
            /* webpackChunkName:"home_patient" */ "../views/home/patient.vue"
          ),
      },
      {
        path: "medicineList",
        name: "medicineList",
        component: () =>
          import(
            /* webpackChunkName:"home_medicineList" */ "../components/commonComponents/myselfReCord.vue"
          ),
      },
      {
        path: "reminder",
        name: "reminder",
        component: () =>
          import(
            /* webpackChunkName:"home_reminder" */ "../components/commonComponents/reminder/reminder.vue"
          ),
      },
      {
        path: "visitRecord",
        name: "visitRecord",
        component: () =>
          import(
            /* webpackChunkName:"home_visitRecord" */ "../components/commonComponents/visitRecord/visitRecord.vue"
          ),
      },
    ],
  },
  {
    path: "/loginData",
    component: () =>
      import(
        /* webpackChunkName:"login" */ "../components/loginData/loginData.vue"
      ),
    meta:{isLogin:false}
  },
  {
    path: "/login",
    name: "login",
    component: () =>
      import(/* webpackChunkName:"login" */ "../views/login/login.vue"),
    children: [
      {
        path: "vertifyLogin",
        name: "vertifyLogin",
        component: () =>
          import(
            /* webpackChunkName:"login" */ "../views/login/vertifyLogin.vue"
          ),
        meta:{isLogin:false}
      },
    ],
    meta:{isLogin:false}
  },
  {
    path: "/chatRoom",
    name: "chatRoom",
    component: () =>
      import(
        /* webpackChunkName:"chatRoom" */ "@/components/commiunication/chatRoom.vue"
      ),
  },
  {
    path: "/prescriptiontemplate",
    name: "prescriptiontemplate",
    component: () =>
      import(
        /* webpackChunkName:"prescriptiontemplate" */ "@/components/commiunication/prescriptiontemplate/prescriptiontemplate.vue"
      ),
  },
  {
    path: "/prescriptionmedicine",
    name: "prescriptionmedicine",
    component: () =>
      import(
        /* webpackChunkName:"prescriptionmedicine" */ "@/components/commiunication/prescriptionmedicine/prescriptionmedicine.vue"
      ),
    children: [
      {
        path: "prescriptionData",
        name: "prescriptionData",
        component: () =>
          import(
            /* webpackChunkName:"prescriptionData" */ "@/components/commiunication/prescriptionData/prescriptionData.vue"
          ),
      },
      {
        path: "drugstorage",
        name: "drugstorage",
        component: () =>
          import(
            /* webpackChunkName:"drugstorage" */ "@/components/commiunication/drugstorage/drugstorage.vue"
          ),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
NProgress.configure({
  easing: "speed", // 动画方式
  speed: 500, // 递增进度条的速度
  showSpinner: false, // 是否显示加载ico
  trickleSpeed: 200, // 自动递增间隔
  minimum: 0.3, // 初始化时的最小百分比
});
router.beforeEach(async () => {
  NProgress.start();
});
router.afterEach(async () => {
  NProgress.done();
  window.scrollTo(0, 0);
});
export default router;
